mongodb c# batch find

181

mongodb c# batch find -

var filter = new BsonDocument();
var options = new FindOptions<BsonDocument>
{
    // Get 100 docs at a time
    BatchSize = 100
};

using (var cursor = await test.FindAsync(filter, options))
{
    // Move to the next batch of docs
    while (await cursor.MoveNextAsync())
    {
        var batch = cursor.Current;
        foreach (var doc in batch)
        {
            // process doc
        }
    }
}

mongodb c# batch find -

var filter = new BsonDocument();
var options = new FindOptions<BsonDocument>
{
    // Get 100 docs at a time
    BatchSize = 100
};

using (var cursor = await test.FindAsync(filter, options))
{
    await cursor.ForEachAsync(doc =>
    {
        // process doc
    });
}

Comments

Submit
0 Comments